package com.kingdee.eas.custom.hr.attendance.client;

import com.kingdee.bos.BOSException;
import com.kingdee.bos.ctrl.extendcontrols.KDBizPromptBox;
import com.kingdee.bos.ctrl.swing.KDCheckBox;
import com.kingdee.bos.ctrl.swing.KDDatePicker;
import com.kingdee.bos.metadata.entity.FilterInfo;
import com.kingdee.bos.metadata.entity.FilterItemInfo;
import com.kingdee.bos.metadata.query.util.CompareType;
import com.kingdee.eas.base.commonquery.client.CustomerParams;
import com.kingdee.eas.basedata.org.AdminOrgUnitInfo;
import com.kingdee.eas.custom.common.client.AdminOrgUtils;
import com.kingdee.eas.hr.time.client.AttendanceManagerPanelUI;

public class AttendanceRecordPanelUI extends AttendanceManagerPanelUI {

	public AttendanceRecordPanelUI() throws Exception {
		super();

	}

	@Override
	public void setCustomerParams(CustomerParams cp) {
		super.setCustomerParams(cp);
		try {
			this.promptBoxOrg.setValue(AdminOrgUtils.getCurrentDefaultAdminRange());
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	@Override
	public void onLoad() throws Exception {
		super.onLoad();
//		this.promptBoxOrg.setEditable(true);
//		
	}

	public FilterInfo getFilterInfo() {
		AdminOrgUnitInfo orgInfo = (AdminOrgUnitInfo) this.promptBoxOrg
				.getData();
		FilterInfo filterInfo = new FilterInfo();

		if (orgInfo == null) {
			filterInfo.getFilterItems().add(new FilterItemInfo("id", null));
			return filterInfo;
		}
		if (orgInfo != null) {
			if (this.chkInclude.isSelected()) {
				FilterInfo orgFi = new FilterInfo();
				orgFi.getFilterItems().add(
						new FilterItemInfo("dept.longNumber", orgInfo
								.getLongNumber()));
				orgFi.getFilterItems().add(
						new FilterItemInfo("dept.longNumber", orgInfo
								.getLongNumber()
								+ "!%", CompareType.LIKE));

				orgFi.setMaskString("(#0 or #1)");
				try {
					filterInfo.mergeFilter(orgFi, "and");
				} catch (BOSException e) {
					super.handUIException(e);
				}
			} else {
				filterInfo.getFilterItems().add(
						new FilterItemInfo("dept.id", orgInfo.getId()
								.toString()));
			}
		}
		return filterInfo;
	}

	public KDBizPromptBox getPromptBoxOrg() {
		return this.promptBoxOrg;
	}

	public KDDatePicker getDatePickFrom() {
		return this.DatePickFrom;
	}

	public KDDatePicker getDatePickerTo() {
		return this.DatePickerTo;
	}

	public KDCheckBox getChkInclude() {
		return this.chkInclude;
	}

}
